<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Droitfeuille extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Iddroitfeuille;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idusers;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idfeuilles;


    /**
     * Parent relation fk_droitfeuille_feuilles1
     *
     * @var Application_Model_Feuilles
     */
    protected $_Feuilles;

    /**
     * Parent relation fk_droitfeuille_users1
     *
     * @var Application_Model_Users
     */
    protected $_Users;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'iddroitfeuille'=>'Iddroitfeuille',
            'idusers'=>'Idusers',
            'idfeuilles'=>'Idfeuilles',
        ));

        $this->setParentList(array(
            'FkDroitfeuilleFeuilles1'=> array(
                    'property' => 'Feuilles',
                    'table_name' => 'Feuilles',
                ),
            'FkDroitfeuilleUsers1'=> array(
                    'property' => 'Users',
                    'table_name' => 'Users',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column iddroitfeuille
     *
     * @param int $data
     * @return Application_Model_Droitfeuille
     */
    public function setIddroitfeuille($data)
    {
        $this->_Iddroitfeuille = $data;
        return $this;
    }

    /**
     * Gets column iddroitfeuille
     *
     * @return int
     */
    public function getIddroitfeuille()
    {
        return $this->_Iddroitfeuille;
    }

    /**
     * Sets column idusers
     *
     * @param int $data
     * @return Application_Model_Droitfeuille
     */
    public function setIdusers($data)
    {
        $this->_Idusers = $data;
        return $this;
    }

    /**
     * Gets column idusers
     *
     * @return int
     */
    public function getIdusers()
    {
        return $this->_Idusers;
    }

    /**
     * Sets column idfeuilles
     *
     * @param int $data
     * @return Application_Model_Droitfeuille
     */
    public function setIdfeuilles($data)
    {
        $this->_Idfeuilles = $data;
        return $this;
    }

    /**
     * Gets column idfeuilles
     *
     * @return int
     */
    public function getIdfeuilles()
    {
        return $this->_Idfeuilles;
    }

    /**
     * Sets parent relation Idfeuilles
     *
     * @param Application_Model_Feuilles $data
     * @return Application_Model_Droitfeuille
     */
    public function setFeuilles(Application_Model_Feuilles $data)
    {
        $this->_Feuilles = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idfeuilles'];
        }

        $this->setIdfeuilles($primary_key);

        return $this;
    }

    /**
     * Gets parent Idfeuilles
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Feuilles
     */
    public function getFeuilles($load = true)
    {
        if ($this->_Feuilles === null && $load) {
            $this->getMapper()->loadRelated('FkDroitfeuilleFeuilles1', $this);
        }

        return $this->_Feuilles;
    }

    /**
     * Sets parent relation Idusers
     *
     * @param Application_Model_Users $data
     * @return Application_Model_Droitfeuille
     */
    public function setUsers(Application_Model_Users $data)
    {
        $this->_Users = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idusers'];
        }

        $this->setIdusers($primary_key);

        return $this;
    }

    /**
     * Gets parent Idusers
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Users
     */
    public function getUsers($load = true)
    {
        if ($this->_Users === null && $load) {
            $this->getMapper()->loadRelated('FkDroitfeuilleUsers1', $this);
        }

        return $this->_Users;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Droitfeuille
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Droitfeuille());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Droitfeuille::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIddroitfeuille() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('iddroitfeuille = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIddroitfeuille()));
    }
}
